//
//  JgAdsRewardVodAdContainer.m
//  AnyThinkSDKDemo
//
//  Created by 李上京 on 2022/10/26.
//  Copyright © 2022 抽筋的灯. All rights reserved.
//

#import "JgAdsRewardVodAdContainer.h"

@interface JgAdsRewardVodAdContainer()<JgAdsRewardVodAdDelegate>

@property(nonatomic, strong) JgAdsRewardVodAd *rewardVodAd;

@end

@implementation JgAdsRewardVodAdContainer
-(void)setDelegate:(id<JgAdsRewardVodAdDelegate>)delegate{
    self.rewardVodAd.delegate = delegate;
}
// MARK: - Init
-(instancetype)initPosId:(NSString *)posId delegate:(id<JgAdsRewardVodAdDelegate>)delegate{
    self = [super init];
    if(self){
        self.rewardVodAd = [JgAdsRewardVodAd new];
        self.rewardVodAd.posId = posId;
        self.rewardVodAd.delegate = delegate;
        if (delegate == nil) {
            self.rewardVodAd.delegate = self;
        }
    }
    return self;
}
- (void)loadRewardVodAd{
    if(self.rewardVodAd){
        [self.rewardVodAd loadAdData];
    }
}
- (void)showRewardVodAdWithRootViewController:(UIViewController *)controller{
    [_rewardVodAd showFromRootViewController:controller];
}
- (void)sendWinNotificationWithPrice:(NSInteger)price{
    [_rewardVodAd sendWinNotificationWithPrice:price];
}
- (void)sendWinFailNotificationReason:(JgAdsBiddingLossReason)lossReason winnerPirce:(NSInteger)winnerPirce{
    [_rewardVodAd sendWinFailNotificationReason:lossReason winnerPirce:winnerPirce];
}
-(void)close{
    _rewardVodAd = nil;
}
- (NSInteger)getBidPrice{
    return _rewardVodAd.bidPrice;
}
#pragma mark -- JgAdsRewardVodAdDelegate
/**
 *  开屏广告素材加载成功
 */
- (void)jgadsRewardVodAdSuccessToLoadAd:(JgAdsRewardVodAd *)rewardVodAd{
#if DEBUG
        NSLog(@"jgads============激励视频-加载成功");
#endif
    if ([self.containerDelegate respondsToSelector:@selector(jgadsContainer_jgadsRewardVodAdDidLoad:withPrice:)]) {
        [self.containerDelegate jgadsContainer_jgadsRewardVodAdDidLoad:self withPrice:rewardVodAd.bidPrice];
    }
}

/**
 *  开屏广告请求失败
 */
- (void)jgadsRewardVodAdFailToLoadAd:(JgAdsRewardVodAd *)rewardVodAd error:(NSError *)error{
#if DEBUG
        NSLog(@"jgads============激励视频-加载失败：%@",error);
#endif
    if ([self.containerDelegate respondsToSelector:@selector(jgadsContainer_jgadsRewardVodAdFailLoadError:)]) {
        [self.containerDelegate jgadsContainer_jgadsRewardVodAdFailLoadError:error];
    }
}
@end
